﻿<?xml version="1.0" encoding="utf-8"?>
<AdoNetDataAccess connection="$ArticleDBConnection$" formatter="bizobjlist of eComSalesOrderItem(product)">
	<FormatterInfo ArticleFieldType="columnName">
		<code for="postEach" on="product">
			<![CDATA[
			try
			{
				  string title = (string)CurrentBizObj.get("baseTitle");
				  int titIndex = title.IndexOf("~!");
				  if(titIndex != -1)
					CurrentBizObj.put("baseTitle", title.Substring(titIndex+2));
					
				if(CurrentBizObj.get("mediaCacheName").ToString().Length==0)
					CurrentBizObj.put("mediaCacheName",info.get("defaultCacheName"));
			}
			catch(Exception e)
			{
			}
		]]>
		</code>
	</FormatterInfo>
	<Sql>
		SELECT 
			o.id,o.idx,o.orderId,o.productId as productId,o.statusId,o.quantity,o.price, o.description, o.calculatedProductPartId
			,a.baseTitle as productBaseTitle,a.summary AS productBaseSummary, a.metaType as productMetaType
			,a.body as productBaseBody,a.translatedBodies as productTranslatedBodies
			,a.translatedTitles as productTranslatedTitles,a.translatedSummaries as productTranslatedSummaries
			,a.translationDetails as productTranslationDetails,a.translatedCaptions as productTranslatedCaptions
			,a.primaryMediaName as productprimaryPicture_name
			,p.sellPrice as productSellPrice,p.sellPriceDescription as productSellPriceDescription,p.partId as productpartId, p.shippingBoxOption as productshippingBoxOption
			,oc.depth as productdepth
		FROM 
			eComSalesOrderItems o 
			LEFT OUTER JOIN Articles a ON o.productId = a.id
			LEFT OUTER JOIN eComProducts p on o.productId=p.id
			LEFT OUTER JOIN ObjectTreeCounts oc on oc.objectId = p.id
		WHERE 
			orderId=@orderId 
		ORDER BY idx
	</Sql>
	<Param name="orderId" type="UniqueIdentifier"/>
</AdoNetDataAccess>
